package com.example.bobo.yuejian322.Fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

import com.example.bobo.yuejian322.Fragment.Club_Fragment.RenqiFragment;
import com.example.bobo.yuejian322.Fragment.Club_Fragment.ZuijingFragment;
import com.example.bobo.yuejian322.Fragment.zhuyeFragment.ActivityFragment;
import com.example.bobo.yuejian322.Fragment.zhuyeFragment.MasterFragment;
import com.example.bobo.yuejian322.Fragment.zhuyeFragment.PlayFragment;
import com.example.bobo.yuejian322.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClubFragment extends Fragment {

    private RadioGroup radioGroup;
    private RenqiFragment renqiFragment;
    private ZuijingFragment zuijingFragment;

    private FragmentManager manager;
    private FragmentTransaction transaction;

    public ClubFragment() {
        // Required empty public constructor
    }
    private void replace(Fragment fragment) {
        transaction = manager.beginTransaction();
        transaction.replace(R.id.club_fragmelayout, fragment);
        transaction.commit();
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup_club);
        manager = getChildFragmentManager();
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.radio_renqi:
                        renqiFragment = new RenqiFragment();
                        replace(renqiFragment);
                        break;

                    case R.id.radio_zuijing:

                        zuijingFragment = new ZuijingFragment();
                        replace(zuijingFragment);

                        break;


                }

            }
        });

        radioGroup.check(R.id.radio_renqi);



    }




    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_club, container, false);
    }

}
